$.fn.dictionaryList = function() {
    
    var $this = this;

    var _init = function()
    { 
        
        var $dictionary = new RockitJS.Model.Database.Dictionary();
        $dictionary.getDictionaryList(_create);
    };
    
    var _create = function($result)
    { 
        var $htmlLink = '<li><a href="#" class="dictionary" name="{TABLE}" title="{LABEL}">{LABEL}</a></li>';
        var $nav = "";
        var $count = $result.rows.length;

        for ($i = 0; $i < $count; $i++) {

            var $label = $result.rows.item($i).labelname;
            var $tablename = $result.rows.item($i).tablename;
            var $link = $htmlLink;

            $link = $link.replace(/{TABLE}/g, $tablename);
            $link = $link.replace(/{LABEL}/g, $label);
            $nav += $link;
        }
        var $oldContent = $($this).html();
        $($this).html($oldContent + $nav);

        $($this).find("a").click(
            function() {

            	var $class = $(this).attr("class");

                if ($class === "download") {
                    $("#content").load("views/download.phtml");
                } else {
                    var $tablename = $(this).attr("name");
                    $("#content").data("table", $tablename);
                	$("#content").load("views/searchword.phtml");
                }

                return false;
  
            }
        );
    };

    _init();
}